<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>ArNetworking: simpleServerExample.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">ArNetworking
   &#160;<span id="projectnumber">dev20180125</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('simpleServerExample_8cpp-example.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">simpleServerExample.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>This is a simple example of an ArNetworking server.This is the simplest possible ArNetworking server. It creates the server but does not try to connect to the robot or any other devices, and provides no services.</p>
<p>For more complete servers that connect to the robot, see simpleRobotServerExample.cpp and <a class="el" href="serverDemo_8cpp.html">serverDemo.cpp</a>.</p>
<div class="fragment"><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;Aria.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="ArNetworking_8h.html">ArNetworking.h</a>&quot;</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> <a name="a0"></a><a class="code" href="simpleServerExample_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div><div class="line">{</div><div class="line">  <a name="a1"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#ad99c16b5d947229d9f8e1c5b2d4cdd73">Aria::init</a>();</div><div class="line">  <a name="_a2"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArArgumentParser.html">ArArgumentParser</a> parser(&amp;argc, argv);</div><div class="line"></div><div class="line">  <span class="comment">// The base server object, manages all connections to clients.</span></div><div class="line">  <a name="_a3"></a><a class="code" href="classArServerBase.html">ArServerBase</a> server;</div><div class="line"></div><div class="line">  <span class="comment">// This object simplifies configuration and opening of the ArServerBase</span></div><div class="line">  <span class="comment">// object.</span></div><div class="line">  <a name="_a4"></a><a class="code" href="classArServerSimpleOpener.html">ArServerSimpleOpener</a> simpleOpener(&amp;parser);</div><div class="line"></div><div class="line">  <span class="comment">// parse the command line. fail and print the help if the parsing fails</span></div><div class="line">  <span class="comment">// or if the help was requested with -help</span></div><div class="line">  parser.<a name="a5"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArArgumentParser.html#a501694b62a7f8b0c3cadd84aeafe1b35">loadDefaultArguments</a>();</div><div class="line">  <span class="keywordflow">if</span> (!simpleOpener.<a name="a6"></a><a class="code" href="classArServerSimpleOpener.html#aa74b2317502c7f1b140742ee7d4f6f45">parseArgs</a>() || !parser.<a name="a7"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArArgumentParser.html#ac3889cbdfa862031c51bf80e06954914">checkHelpAndWarnUnparsed</a>())</div><div class="line">  {    </div><div class="line">    simpleOpener.<a name="a8"></a><a class="code" href="classArServerSimpleOpener.html#abf0eceb61b0aa727cce24d27e8362bf3">logOptions</a>();</div><div class="line">    <a name="a9"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(1);</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Use the ArSimpleOpener to open the server port</span></div><div class="line">  <span class="keywordflow">if</span> (!simpleOpener.<a name="a10"></a><a class="code" href="classArServerSimpleOpener.html#a6429c1069dee5edc19fb7dc94078bed0">open</a>(&amp;server))</div><div class="line">  {</div><div class="line">    <a name="a11"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a name="a12"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;Error: Could not open server on port %d&quot;</span>, simpleOpener.<a name="a13"></a><a class="code" href="classArServerSimpleOpener.html#aaa66363344c96095c0158027a3b6809c">getPort</a>());</div><div class="line">    exit(1);</div><div class="line">  }</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line">  <span class="comment">// The simple opener might have information to display right before starting </span></div><div class="line">  <span class="comment">// the server thread:</span></div><div class="line">  simpleOpener.<a name="a14"></a><a class="code" href="classArServerSimpleOpener.html#ad05fedc301ab89072e61879999463d17">checkAndLog</a>();</div><div class="line"></div><div class="line">  <span class="comment">// now let the server base run in a new thread, accepting client connections.</span></div><div class="line">  server.<a name="a15"></a><a class="code" href="classArServerBase.html#a93c742ddc58a8f035a0d1b9c1fae4599">runAsync</a>();</div><div class="line"></div><div class="line">  <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a name="a16"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Server is now running... Press Ctrl-C to exit.&quot;</span>);</div><div class="line"></div><div class="line"></div><div class="line">  <span class="keywordflow">while</span>(<span class="keyword">true</span>)</div><div class="line">    <a name="a17"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#ga4dfb878a3f9123b8dd96ae05b2fd94cb">ArUtil::sleep</a>(500);</div><div class="line">  <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(0);</div><div class="line">}</div><div class="line"></div><div class="line"></div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
